package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.WyNoticeMapper;
import com.ruoyi.park.domain.WyNotice;
import com.ruoyi.park.service.IWyNoticeService;

/**
 * 园区公告Service业务层处理
 *
 * @author Felix
 * @date 2022-04-16
 */
@Service
public class WyNoticeServiceImpl implements IWyNoticeService {
    @Autowired
    private WyNoticeMapper wyNoticeMapper;

    /**
     * 查询园区公告
     *
     * @param id 园区公告ID
     * @return 园区公告
     */
    @Override
    public WyNotice selectWyNoticeById(String id) {
        return wyNoticeMapper.selectWyNoticeById(id);
    }

    /**
     * 查询园区公告列表
     *
     * @param wyNotice 园区公告
     * @return 园区公告
     */
    @Override
    public List<WyNotice> selectWyNoticeList(WyNotice wyNotice) {
        return wyNoticeMapper.selectWyNoticeList(wyNotice);
    }

    /**
     * 新增园区公告
     *
     * @param wyNotice 园区公告
     * @return 结果
     */
    @Override
    public int insertWyNotice(WyNotice wyNotice) {
        wyNotice.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        wyNotice.setCreateTime(DateUtils.getNowDate());
        wyNotice.setCreateBy(SecurityUtils.getUsername());
        return wyNoticeMapper.insertWyNotice(wyNotice);
    }

    /**
     * 修改园区公告
     *
     * @param wyNotice 园区公告
     * @return 结果
     */
    @Override
    public int updateWyNotice(WyNotice wyNotice) {
        wyNotice.setUpdateTime(DateUtils.getNowDate());
        wyNotice.setUpdateBy(SecurityUtils.getUsername());
        return wyNoticeMapper.updateWyNotice(wyNotice);
    }

    /**
     * 批量删除园区公告
     *
     * @param ids 需要删除的园区公告ID
     * @return 结果
     */
    @Override
    public int deleteWyNoticeByIds(String[] ids) {
        return wyNoticeMapper.deleteWyNoticeByIds(ids);
    }

    /**
     * 删除园区公告信息
     *
     * @param id 园区公告ID
     * @return 结果
     */
    @Override
    public int deleteWyNoticeById(String id) {
        return wyNoticeMapper.deleteWyNoticeById(id);
    }
}
